<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="项目配置," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="&amp;#x5F15;&amp;#x8A00;:&amp;#x5728;Xcode6&amp;#x4E4B;&amp;#x524D;, &amp;#x521B;&amp;#x5EFA;&amp;#x4E00;&amp;#x4E2A;&amp;#x65B0;&amp;#x5DE5;&amp;#x7A0B; Xcode&amp;#x4F1A;&amp;#x5728; Supporting files &amp;#x6587;&amp;#x4EF6;&amp;#x5939;&amp;#x4E0B;&amp;#x9762;&amp;#x81EA;&amp;#x52A">
<meta property="og:type" content="article">
<meta property="og:title" content="iOS开发 - 关于 pch 文件的创建与配置">
<meta property="og:url" content="http://www.licheng244.com/posts/2016-11/01-1.html">
<meta property="og:site_name" content="LiCheng的博客">
<meta property="og:description" content="&amp;#x5F15;&amp;#x8A00;:&amp;#x5728;Xcode6&amp;#x4E4B;&amp;#x524D;, &amp;#x521B;&amp;#x5EFA;&amp;#x4E00;&amp;#x4E2A;&amp;#x65B0;&amp;#x5DE5;&amp;#x7A0B; Xcode&amp;#x4F1A;&amp;#x5728; Supporting files &amp;#x6587;&amp;#x4EF6;&amp;#x5939;&amp;#x4E0B;&amp;#x9762;&amp;#x81EA;&amp;#x52A">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1975627-a1ba4bb86439eb2d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1975627-33c0f71c97041e3b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1975627-95572e917b302a33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2017-09-18T08:56:44.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="iOS开发 - 关于 pch 文件的创建与配置">
<meta name="twitter:description" content="&amp;#x5F15;&amp;#x8A00;:&amp;#x5728;Xcode6&amp;#x4E4B;&amp;#x524D;, &amp;#x521B;&amp;#x5EFA;&amp;#x4E00;&amp;#x4E2A;&amp;#x65B0;&amp;#x5DE5;&amp;#x7A0B; Xcode&amp;#x4F1A;&amp;#x5728; Supporting files &amp;#x6587;&amp;#x4EF6;&amp;#x5939;&amp;#x4E0B;&amp;#x9762;&amp;#x81EA;&amp;#x52A">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/1975627-a1ba4bb86439eb2d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://www.licheng244.com/posts/2016-11/01-1.html"/>


  <title> iOS开发 - 关于 pch 文件的创建与配置 | LiCheng的博客 </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">LiCheng的博客</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-lifes">
          <a href="/lifes" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            生活
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                iOS开发 - 关于 pch 文件的创建与配置
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-11-01T00:00:00+08:00" content="2016-11-01">
              2016-11-01
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/iOS开发-项目管理/" itemprop="url" rel="index">
                    <span itemprop="name">iOS开发__项目管理</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/posts/2016-11/01-1.html#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="posts/2016-11/01-1.html" itemprop="commentsCount"></span>
                </a>
              </span>
            
          


          

          
          
             <span id="/posts/2016-11/01-1.html" class="leancloud_visitors" data-flag-title="iOS开发 - 关于 pch 文件的创建与配置">
               &nbsp; | &nbsp;
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p><strong>&#x5F15;&#x8A00;:</strong><br>&#x5728;Xcode6&#x4E4B;&#x524D;, &#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x5DE5;&#x7A0B; Xcode&#x4F1A;&#x5728; Supporting files &#x6587;&#x4EF6;&#x5939;&#x4E0B;&#x9762;&#x81EA;&#x52A8;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;&#x201C;&#x5DE5;&#x7A0B;&#x540D;-Prefix.pch&#x201D;&#x6587;&#x4EF6;, &#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x5934;&#x6587;&#x4EF6;, pch&#x5934;&#x6587;&#x4EF6;&#x7684;&#x5185;&#x5BB9;&#x80FD;&#x88AB;&#x9879;&#x76EE;&#x4E2D;&#x7684;&#x5176;&#x4ED6;&#x6240;&#x6709;&#x6E90;&#x6587;&#x4EF6;&#x5171;&#x4EAB;&#x548C;&#x8BBF;&#x95EE;&#x3002;&#x662F;&#x4E00;&#x4E2A;&#x9884;&#x7F16;&#x8BD1;&#x6587;&#x4EF6;&#x3002;</p>
<p>Xcode6&#x4EE5;&#x540E;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#x65F6;, &#x4E0D;&#x518D;&#x4F1A;&#x81EA;&#x52A8;&#x751F;&#x6210;pch&#x6587;&#x4EF6;, &#x9700;&#x8981;&#x6211;&#x4EEC;&#x624B;&#x52A8;&#x521B;&#x5EFA;&#x3002;</p>
</blockquote>
<a id="more"></a>
<hr>
<h3 id="pch&#x7684;&#x4F5C;&#x7528;"><a href="#pch&#x7684;&#x4F5C;&#x7528;" class="headerlink" title="pch&#x7684;&#x4F5C;&#x7528;"></a>pch&#x7684;&#x4F5C;&#x7528;</h3><ul>
<li>&#x5B58;&#x653E;&#x4E00;&#x4E9B;&#x5168;&#x5C40;&#x7684;&#x5B8F;&#x5B9A;&#x4E49;(&#x6574;&#x4E2A;&#x9879;&#x76EE;&#x4E2D;&#x90FD;&#x7528;&#x5F97;&#x4E0A;&#x7684;&#x5B8F;);</li>
<li>&#x7528;&#x6765;&#x5305;&#x542B;&#x4E00;&#x4E9B;&#x5927;&#x591A;&#x6570;&#x7C7B;&#x6240;&#x7528;&#x5230;&#x7684;&#x5934;&#x6587;&#x4EF6;(&#x6574;&#x4E2A;&#x9879;&#x76EE;&#x4E2D;&#x90FD;&#x7528;&#x5F97;&#x4E0A;&#x7684;&#x5934;&#x6587;&#x4EF6;);</li>
<li>&#x8BBE;&#x7F6E;&#x81EA;&#x52A8;&#x6253;&#x5F00;&#x6216;&#x8005;&#x5173;&#x95ED;&#x65E5;&#x5FD7;&#x8F93;&#x51FA;&#x529F;&#x80FD;;</li>
</ul>
<h3 id="&#x5728;Xcode6&#x4EE5;&#x540E;&#x7684;&#x7248;&#x672C;&#x4E2D;&#x6DFB;&#x52A0;pch&#x6587;&#x4EF6;"><a href="#&#x5728;Xcode6&#x4EE5;&#x540E;&#x7684;&#x7248;&#x672C;&#x4E2D;&#x6DFB;&#x52A0;pch&#x6587;&#x4EF6;" class="headerlink" title="&#x5728;Xcode6&#x4EE5;&#x540E;&#x7684;&#x7248;&#x672C;&#x4E2D;&#x6DFB;&#x52A0;pch&#x6587;&#x4EF6;"></a>&#x5728;Xcode6&#x4EE5;&#x540E;&#x7684;&#x7248;&#x672C;&#x4E2D;&#x6DFB;&#x52A0;pch&#x6587;&#x4EF6;</h3><ol>
<li><p>command+N, &#x6253;&#x5F00;&#x65B0;&#x5EFA;&#x6587;&#x4EF6;&#x7A97;&#x53E3;: iOS -&gt; Other -&gt; PCH File, &#x521B;&#x5EFA;&#x4E00;&#x4E2A;pch&#x6587;&#x4EF6;: <img src="http://upload-images.jianshu.io/upload_images/1975627-a1ba4bb86439eb2d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
</li>
<li><p>&#x5728;&#x5DE5;&#x7A0B;&#x7684; Targets &#x91CC;&#x8FB9;&#x7684; Building Setting &#x4E2D;&#x641C;&#x7D22; Prefix Header, &#x7136;&#x540E;&#x628A; Precompile Prefix Header &#x53F3;&#x8FB9;&#x7684;NO&#x6539;&#x4E3A;Yes, &#x9884;&#x7F16;&#x8BD1;&#x540E;&#x7684;pch&#x6587;&#x4EF6;&#x4F1A;&#x88AB;&#x7F13;&#x5B58;&#x8D77;&#x6765;, &#x53EF;&#x4EE5;&#x63D0;&#x9AD8;&#x7F16;&#x8BD1;&#x901F;&#x5EA6;, &#x5982;&#x56FE;&#x6240;&#x793A;&#xFF1A;<br><img src="http://upload-images.jianshu.io/upload_images/1975627-33c0f71c97041e3b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
</li>
<li><p>&#x8BBE;&#x7F6E;pch&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;, $(SRCROOT)&#x4EE3;&#x8868;&#x5DE5;&#x7A0B;&#x7684;&#x6839;&#x76EE;&#x5F55;&#xFF0C;&#x7136;&#x540E;&#x540E;&#x8FB9;&#x8FD8;&#x8981;&#x52A0;&#x4E0A;pch&#x5728;&#x5F53;&#x524D;&#x9879;&#x76EE;&#x7684;&#x8DEF;&#x5F84;&#xFF0C;&#x6240;&#x4EE5;&#x5B8C;&#x6574;&#x7684;pch&#x6587;&#x4EF6;&#x7684;&#x8DEF;&#x5F84;&#x5C31;&#x662F;&#xFF1A;<code>$(SRCROOT)/PchDemo/Tools/PrefixHeader.pch</code> ; &#x77E5;&#x9053;&#x4E86;pch&#x6587;&#x4EF6;&#x7684;&#x76EE;&#x5F55;, &#x63A5;&#x4E0B;&#x6765;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4E86;, &#x5728;&#x5DE5;&#x7A0B;&#x7684; Targets &#x91CC;&#x8FB9;&#x7684; Building Setting &#x4E2D;&#x641C;&#x7D22; Prefix Header, &#x627E;&#x5230; Prefix Header &#x5C5E;&#x6027;, &#x53CC;&#x51FB;&#x540E;&#x9762;&#x7A7A;&#x767D;&#x5904;, &#x5C06;pch&#x7684;&#x8DEF;&#x5F84;&#x586B;&#x5199;&#x5230;&#x91CC;&#x9762;, &#x5982;&#x56FE;&#x6240;&#x793A;&#xFF1A;<br><img src="http://upload-images.jianshu.io/upload_images/1975627-95572e917b302a33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
</li>
<li><p>command + B &#x7F16;&#x8BD1;&#x4E00;&#x4E0B;, &#x5982;&#x679C;&#x6CA1;&#x6709;&#x62A5;&#x9519;, &#x8BF4;&#x660E;pch&#x6587;&#x4EF6;&#x7684;&#x521B;&#x5EFA;&#x548C;&#x914D;&#x7F6E;&#x6210;&#x529F;&#x4E86;&#x3002;</p>
</li>
</ol>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/项目配置/" rel="tag">#项目配置</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/posts/2016-10/31-1.html" rel="next" title="iOS开发 - 遍历集合(NSArray，NSDictionary、NSSet)方法总结">
                <i class="fa fa-chevron-left"></i> iOS开发 - 遍历集合(NSArray，NSDictionary、NSSet)方法总结
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/posts/2016-11/03-2.html" rel="prev" title="iOS开发 - 数据存储 CoreData 的使用">
                iOS开发 - 数据存储 CoreData 的使用 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>





    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="posts/2016-11/01-1.html"
           data-title="iOS开发 - 关于 pch 文件的创建与配置" data-url="http://www.licheng244.com/posts/2016-11/01-1.html">
      </div>
    

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/avatar.jpg"
               alt="Li Cheng" />
          <p class="site-author-name" itemprop="name">Li Cheng</p>
          <p class="site-description motion-element" itemprop="description">| 写写代码 | 做做设计 | <br>记录着工作和学习中的点点滴滴 ~~~</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">17</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">8</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">13</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#pch的作用"><span class="nav-number">1.</span> <span class="nav-text">pch的作用</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#在Xcode6以后的版本中添加pch文件"><span class="nav-number">2.</span> <span class="nav-text">在Xcode6以后的版本中添加pch文件</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Li Cheng</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"licheng244344094"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = false;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = decodeURIComponent(data.url);
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title >= 0 || index_content >= 0 ){
                                isMatch = true;
								if (i == 0) {
                                    first_occur = index_content;
                                }
                            } 
							
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("SJtE0CaYCSQVrkVXmWMYWJOd-gzGzoHsz", "TfVyU54NEToMYg0SId3KELgz");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  


</body>
</html>
